/******************************************************************************
//             INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in accordance with the terms of that agreement.
//        Copyright (c) 2000-2001 Intel Corporation. All Rights Reserved.
//
//  Description:
//      Intel(R) JPEG library for X platform 
//
********************************************************************************/
#include "_ijx.h"

/******************************************************************************
// Name:            ijDecodeScanSpec
// Description:     Decode Scan info of JPEG
// Input Arguments:
//         pStream: Identifies IJBITTREAMSTATE data structure.
// Output Arguments:
//    pDecodeState: Identifies IJDECODESTATE strcuture.
//                          
// Returns:          
//        [Success] IJX_RTCODE_OK
//        [Failure] IJX_RTCODE_BAGARG
//                  IJX_RTCODE_F_INSUFFICIENTBUF
//                  IJX_RTCODE_E_ERRPARAM
//                  
******************************************************************************/
IJXRESULT ijInitScanSpecInv(IJBITTREAMSTATE *pStream,
                           IJDECODESTATE *pDecodeState)
{
    int i, nIndex;
    int nNumComp=pDecodeState->imageSpec.nNumComponent;
    IJCOMPSPEC *pCompSpec=pDecodeState->compSpec;

    for (i=0; i<nNumComp; i++) {
        nIndex=pCompSpec[i].nDCHuffTableIndex;
        pDecodeState->paIdxDCTDequantTable[i]=&(pDecodeState->dctDequantTable[nIndex*64]);
        nIndex=pCompSpec[i].nDCHuffTableIndex;
        pDecodeState->paIdxDCHuffTable[i]=&(pDecodeState->dcHuffTable[nIndex]);
        nIndex=pCompSpec[i].nACHuffTableIndex;
        pDecodeState->paIdxACHuffTable[i]=&(pDecodeState->acHuffTable[nIndex]);
        pDecodeState->dcPred[i]=0;
    }

    pDecodeState->nHMCUCurPos=0;
    pDecodeState->nVMCUCurPos=0;
    /* MCU Counter */
//    pDecodeState->counter.nFrameMCUCounter+=pDecodeState->counter.nScanMCUCounter;
//    pDecodeState->counter.nScanMCUCounter=0;
    /* Scan Counter */
    pDecodeState->counter.nScanCounter++;
    /* RST Counter */
    pDecodeState->counter.nDRICounter=pDecodeState->nRstInterval;
    pDecodeState->counter.nRSTCounter=0;

    pDecodeState->progSpec.nEOBRun=0;

    pStream->nPrefetchedBits=0;
    pStream->nNumValidPrefetchedBits=0;

    return IJX_RTCODE_OK;
}

/* EOF */
